﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WebApplication
{
    public partial class _Default : System.Web.UI.Page
    {
        protected override void OnError(EventArgs e)
        {
            Exception ex = Server.GetLastError();
            Server.ClearError();

            Response.Write(Server.HtmlEncode(ex.Message));
        }

        protected void ObjectDataSource1_Selected(object sender, ObjectDataSourceStatusEventArgs e)
        {
            if (e.ReturnValue == null) return;

            if (e.ReturnValue.GetType() == typeof(System.Int32))
            {
                int count = (int)e.ReturnValue;
                MatchLabel.Text = count.ToString("n0");
            }
        }
        protected void DeleteAllButton_Click(object sender, EventArgs e)
        {
            using (WebApplication.Log4NetDataSetTableAdapters.LogTableAdapter adapter = new Log4NetDataSetTableAdapters.LogTableAdapter())
                adapter.DeleteAll();
            GridView1.PageIndex = 0;
            Page.DataBind();
        }
        protected void ApplyFilterButton_Click(object sender, EventArgs e)
        {
            GridView1.PageIndex = 0;
        }
        protected void FormView1_ItemDeleted(object sender, FormViewDeletedEventArgs e)
        {
            Page.DataBind();
        }
        protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
        {
            if (GridView1.PageIndex >= GridView1.PageCount
                && GridView1.PageIndex != 0)
                GridView1.PageIndex = GridView1.PageCount - 1;
        }
    }
}
